package com.shop.cereshop.commons.enums;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * @description:  互动消息类型
 * @author zdd
 * @date 2025/10/16 10:07
 * @version 1.0
 */
public enum InteractiveMsgTypeEnum {
    //互动消息类型 1-评论了你 2-回复了你
    COMMENT(1, "评论了你 "),
    REPLY(2, "回复了你"),
    ;

    private final Integer code;
    private final String msg;

    private static final Map<Integer, InteractiveMsgTypeEnum> CODE_MAP = new HashMap<>();

    static {
        for (InteractiveMsgTypeEnum type : InteractiveMsgTypeEnum.values()) {
            CODE_MAP.put(type.getCode(), type);
        }
    }

    InteractiveMsgTypeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public static String getMsgByCode(Integer code) {
        if (Objects.isNull(code)) {
            return "";
        }
        InteractiveMsgTypeEnum type = CODE_MAP.get(code);
        return type != null ? type.getMsg() : "";
    }
}
